package cn.luischen.controller.admin;

import cn.luischen.constant.ErrorConstant;
import cn.luischen.controller.BaseController;
import cn.luischen.dto.cond.CommentCond;
import cn.luischen.exception.BusinessException;
import cn.luischen.model.CommentDomain;
import cn.luischen.model.UserDomain;
import cn.luischen.service.comment.CommentService;
import cn.luischen.utils.APIResponse;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;

import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
import org.junit.Rule;
import org.junit.runner.RunWith;
import org.junit.rules.ExpectedException;
import org.junit.Test;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.stubbing.Answer;
import java.lang.reflect.Method;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.parser.ParserConfig;
import java.util.Map;
import java.util.List;
import com.unitspirit.runtime.*;

/**
 * The class contains tests for the class cn.luischen.controller.admin.CommentController.
 *
 * @generatedBy UnitSpirit CreateTemplateTestFile4
 * @version 1.0.9.11 
 */
@PowerMockIgnore({ "javax.management.*" })
@RunWith(PowerMockRunner.class)
@PrepareForTest({ cn.luischen.dto.cond.CommentCond.class })
public class CommentController_index_WGTest {
	@Rule
	public ExpectedException unitspirit_thrown = ExpectedException.none();

	/**
	 * 测试方法初始化.
	 * 
	 * @throws Exception 
	 *         if the initialization fails for some reason 
	 *  
	 * @generatedBy UnitSpirit at 2021-12-08 11:01:15
	 */
	@org.junit.Before
	public void setUp() throws Exception {
		try {
			GlobalUnitInit.init();
			MockitoAnnotations.initMocks(this);
			ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

	@InjectMocks
	cn.luischen.controller.admin.CommentController unitspirit_fixture;

	@Mock
	cn.luischen.service.comment.CommentService mock_CommentService;

	/**
	 * @date 2021-12-08 11:01:16
	 * @see cn.luischen.controller.admin.CommentController#index
	 * @category null  
	 * @author UnitSpirit   
	 */
	@Test
	public void test_index_1207_114013_277_2_01() throws Throwable {
		unitspirit_fixture = PowerMockito.spy(unitspirit_fixture);
		//被测函数参数定义
		int int_p_0 = 1;
		int int_p_1 = 15;
		javax.servlet.http.HttpServletRequest HttpServletRequest_p_2 = Mockito
				.mock(javax.servlet.http.HttpServletRequest.class);
		//成员变量设置

		//返回值定义 
		String result_expected = "\"admin/comment_list\"";

		cn.luischen.model.UserDomain mock_result_UserDomain2 = JSON
				.parseObject(
						"{\"activated\":0,\"created\":1490756162,\"email\":\"1034683568@qq.com\",\"groupName\":\"visitor\",\"logged\":0,\"password\":\"0287040c474dbf44cdeb17eebb99d828\",\"screenName\":\"admin1\",\"uid\":1,\"username\":\"admin\"}",
						cn.luischen.model.UserDomain.class);
		PowerMockito.doReturn(mock_result_UserDomain2).when(unitspirit_fixture)
				.user(Mockito.any(javax.servlet.http.HttpServletRequest.class));
		cn.luischen.dto.cond.CommentCond mock_sub_caller_CommentCond1 = PowerMockito
				.mock(cn.luischen.dto.cond.CommentCond.class);

		PowerMockito.whenNew(cn.luischen.dto.cond.CommentCond.class)
				.withNoArguments().thenReturn(mock_sub_caller_CommentCond1);

		String unitspirit_result = unitspirit_fixture.index(int_p_0, int_p_1,
				HttpServletRequest_p_2);
		//getAssertCase 
		UnitAssert.assertEquals(result_expected, unitspirit_result);
	}
}
